home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 120 / text0000.txt < prev   
Encoding:
Text File  |  1996-08-06  |  31.7 KB  |  769 lines

  1.  
  2. Archive-name: internationalization/programming-faq
  3. Posting-Frequency: monthly
  4. Version: 1.91
  5.  
  6.  
  7.           Programming for Internationalization
  8.  
  9.               Michael K. Gschwind
  10.  
  11.  
  12.  
  13. DISCLAIMER: THE AUTHOR MAKES NO WARRANTY OF ANY KIND WITH REGARD TO
  14. THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16.  
  17. Note: Most of this was tested on a Sun 10, running SunOS 4.1.* - other
  18. systems might differ slightly
  19.  
  20. This FAQ discusses topics related to internationalization. Simple i18n
  21. support for Europe, Latin America, and the Middle East might use of
  22. the ISO 8859-X based 8 bit character sets.  For wider portability, a
  23. standard such as Unicode is in order.
  24.  
  25. This FAQ discusses how to program applications which support the use
  26. European (Latin American) national character sets on UNIX-based
  27. systems and standard C environments, and discusses some choices with
  28. respect to character sets.
  29.  
  30.  
  31. INTRODUCTION 
  32.  
  33. Most of the information given here is independent of the character
  34. encoding used (e.g. DEC MCS, ISO Latin-X, etc.), but can be applied to
  35. any character set, providing the programming environment has
  36. provisions for this standard.
  37.  
  38.  
  39. 1. Which coding should I use for accented characters?
  40. Use the internationally standardized ISO-8859-1 character set to type
  41. accented characters. This character set contains all characters
  42. necessary to type (West) European languages. This encoding is also the
  43. preferred encoding on the Internet.  ISO 8859-X character sets use the
  44. characters 0xa0 through 0xff to represent national characters, while
  45. the characters in the 0x20-0x7f range are those used in the US-ASCII
  46. (ISO 646) character set.  Thus, ASCII text is a proper subset of all
  47. ISO 8859-X character sets.  
  48.  
  49. The characters 0x80 through 0x9f are earmarked as extended control
  50. chracters, and are not used for encoding characters.  These characters
  51. are not currently used to specify anything.  A practical reason for
  52. this is interoperability with 7 bit devices (or when the 8th bit gets
  53. stripped by faulty software).  Devices would then interpret the character
  54. as some control character and put the device in an undefined state.
  55. (When the 8th bit gets stripped from the characters at 0xa0 to 0xff, a
  56. wrong character is represented, but this cannot change the state of a
  57. terminal or other device.)
  58.  
  59. This character set is also used by AmigaDOS, MS-Windows, VMS (DEC MCS
  60. is practically equivalent to ISO 8859-1) and (practically all) UNIX
  61. implementations.  MS-DOS normally uses a different character set and
  62. is not compatible with this character set. (It can, however, be
  63. translated to this format with various tools. See section 5.)
  64.  
  65. Footnote: Supposedly, IBM code page 819 is fully ISO 8859-1 compliant.
  66.  
  67.  
  68. ISO 8859-1 supports the following languages:
  69. Afrikaans, Basque, Catalan, Danish, Dutch, English, Faeroese, Finnish,
  70. French, Galician, German, Icelandic, Irish, Italian, Norwegian,
  71. Portuguese, Spanish and Swedish.
  72.  
  73. (It has been called to my attention that Albanian can be written with
  74. ISO 8859-1 also.  However, from a standards point of view, ISO 8859-2
  75. is the appropriate character set for Balkan countries.)
  76.  
  77. ISO 8859-1 is just one part of the ISO-8859 standard, which specifies
  78. several character sets:
  79. 8859-1    Europe, Latin America
  80. 8859-2  Eastern Europe
  81. 8859-3  SE Europe/miscellaneous (Esperanto, Maltese, etc.) 
  82. 8859-4  Scandinavia/Baltic (mostly covered by 8859-1 also)
  83. 8859-5  Cyrillic
  84. 8859-6  Arabic
  85. 8859-7  Greek 
  86. 8859-8  Hebrew
  87. 8859-9  Latin5, same as 8859-1 except for Turkish instead of Icelandic
  88. 8859-10 Latin6, for Lappish/Nordic/Eskimo languages
  89.  
  90. Another nascent standard is UNICODE (ISO 10646).  UNICODE is an
  91. extension of ISO 8859-1 (which itself is an extension of US-ASCII) to
  92. wide characters.  Thus, most of the world's languages (including
  93. Japanese, Korean, Chinese...) can be covered.
  94.  
  95. Unicode is advantageous because one character set suffices to encode
  96. all the world's languages.  The degree of Unicode support available
  97. depends on the operating system and on application availability. 
  98. However very few programs support wide characters. Thus, a `cheap'
  99. upgrade from 7 bit US-ASCII might be to only 8 bit wide character sets
  100. (such as the ISO 8859-X).  Unfortunately, some programmers still
  101. insist on using the `spare' eigth bit for clever tricks, which will
  102. make conversion more difficult.
  103.  
  104. Footnote: Some people have complained about missing characters,
  105.           e.g. French users about a missing 'oe'.  Note that oe is 
  106.           not a character, but a ligature (a combination of two
  107.           characters for typographical purposes).  Ligatures are not 
  108.           part of the ISO 8859-X standard.  (Although 'oe' used to 
  109.           be in the draft 8859-1 standard before it was unmasked as
  110.           `mere' ligature.)
  111.  
  112.  
  113.  
  114.  
  115. 2. Choosing the character set encoding
  116.  
  117. Depending on your needs, you will probably want to choose different
  118. solutions.  A quick shot i18n of US programs might simply be going to
  119. 8 bit and use one of the ISO 8859-X character sets.
  120.  
  121. If you have a choice and start from scratch, you might want to
  122. consider Unicode.  There are several aspects to choosing a particular
  123. character set (and you may want to decide on different character sets
  124. for different purposes):
  125. 1) what codeset should the application run in?  
  126. 2) what codeset should files be saved in 
  127. 3) what codeset is used as output (to screens etc.) and 
  128. 4) should wide characters or multi-byte characters be used (this
  129.    choice may be different for each of points 1-3)
  130.  
  131. For example, if portability of your files across cultural borders is
  132. an objective, you might want to use some form of Unicode encoding to
  133. achieve this.  If interaction with other tools in your environment is
  134. the main objective, and these tools use an encoding different from
  135. Unicode, this character set might be used instead.  
  136.  
  137. Using Unicode internally but writing a different format to files may
  138. sound funny (esp. if the output file format is only a subset of
  139. Unicode), but you would only have to adapt the file write and read
  140. functions and the same program will be able to execute in all
  141. countries your product might be used...)
  142.  
  143. Also, terminals and/or which process Unicode may not be available (or
  144. you might have to support legacy hardware), so you might need to adapt
  145. the output format to a third standard.
  146.  
  147.  
  148. 2. Getting your environment right for ISO 8859-X
  149. To configure your environment such that you can enter, process and
  150. display 8 bit ISO characters, check out the ISO-8859-1 FAQ available
  151. via anonymous ftp from ftp.vlsivie.tuwien.ac.at in
  152. /pub/8bit/FAQ-ISO-8859-1.  
  153.  
  154. If you use a different encoding, you will probably also have to
  155. configure your system to fully support that encoding.
  156.  
  157.  
  158.  
  159. 3. Setting your environment for ISO-C (ANSI-C) programs
  160. The ISO C Standard (ANSI C Standard 4.4) defines several functions for
  161. supporting localization. To set your international environment on
  162. program startup, you should make one or several calls to the setlocale
  163. functions.  Calls to this function will predetermine the reaction of
  164. other localization functions according to your language/country
  165. environment.
  166.  
  167. To configure a particular aspect of you environment, say the number
  168. representation, you would call
  169. --
  170. setlocale (LC_NUMERIC, "Germany");
  171. --
  172.  
  173. This call would set all number representation functions defined in the
  174. localization set to return numbers in the format used in Germany.  If
  175. the call was successful, setlocale will return the name of your
  176. locale.  A NULL return value indicates failure.  Note that the
  177. environments are predetermined outside your C program by the system
  178. you run on. (So the example given here is likely to fail on all but a
  179. few systems.) Check the setlocale manual page or your system
  180. documentation to find out about the environments available.
  181.  
  182. There are several LOCALE types available for different localization
  183. aspects (currency sign, number representation, characters sets). The
  184. value they can take is highly system dependent. Also, it should be up
  185. to the user to define the locale environment he needs. 
  186.  
  187. A C program inherits its locale environment variables when it starts up.
  188. This happens automatically.  However, these variables do not
  189. automatically control the locale used by the library functions, because
  190. ISO/ANSI C says that all programs start by default in the standard C
  191. locale.  To use the locales specified by the environment, The POSIX
  192. standard defines the following call:
  193. -----
  194. setlocale (LC_ALL, "");
  195. -----
  196.  
  197. Of course, you can only set part of your environment, by calling, say:
  198. ----
  199. setlocale (LC_CTYPE, "");
  200. ----
  201. This only defines the character classification macros (defined in
  202. ctype.h).
  203.  
  204. This is a list of local categories:
  205.  
  206.                    Effect of Specifying   Environment Variable
  207.      category      the Value              Affected
  208.      __________________________________________________________
  209.  
  210.      LC_ALL        Sets or queries        LANG
  211.                    entire environment
  212.      LC_COLLATE    Changes or queries     LC_COLLATE
  213.                    collation sequences
  214.      LC_CTYPE      Changes or queries     LC_CTYPE
  215.                    character classifi-
  216.                    cation
  217.      LC_NUMERIC    Changes or queries     LC_NUMERIC
  218.                    number format infor-
  219.                    mation
  220.      LC_TIME       Changes or queries     LC_TIME
  221.                    time conversion
  222.                    parameters
  223.      LC_MONETARY   Changes or queries     LC_MONETARY
  224.                    monetary information
  225.  
  226.  
  227.  
  228.  
  229. 4. Using the locale information for character classification
  230. If you write a program which supports international use, you should
  231. use the available standardized functions, as only these will be
  232. influenced by the setlocale call. Thus, if you want to convert a
  233. capital letter in c to a lower case letter in l, _don't_ write:
  234.  
  235. l = c - 'A' + 'a';
  236.  
  237. While this will work for characters in the US-ASCII character set, it
  238. will not work with many other character sets. The following,
  239. standard-conformant code will:
  240.  
  241. #include <ctype.h>
  242.  
  243. ....
  244.  
  245. l = tolower(c);
  246.  
  247. Also note that the second code may actually be faster than even the
  248. full "C" locale functionality (for most implementations), as it
  249. replaces a complex expression ( (c<='Z' && c>='A')? c-'A'+a:c; )by a simple
  250. table lookup!
  251.  
  252. Note that this ISO standard is independent of the character set
  253. encoding used!
  254.  
  255.  
  256.  
  257. 5. Language independent messages
  258. There are two competing standards for language independent messages:
  259. one by X/Open, and another one propagated by Sun.  The X/Open standard
  260. seems to have found a larger following as it has been around for a
  261. longer time.  As of Solaris 2.x, Sun supports both the X/Open and Sun
  262. message standards.  (they used to support only their own "standard".)
  263.  
  264. 5.1 X/Open language independent messages
  265. X/Open defines a method for providing language-independent messages.
  266. Error messages are kept in a catalog which is opened upon program
  267. start with a locale specification.  Then the message number and a set
  268. specification are used to index the message catalog.  A default fourth
  269. argument is specified which will be printed if a particular message
  270. cannot be found in the catalog. 
  271.  
  272. Here is the world-famous C program using the language-independent
  273. X/Open message standard:
  274. --------------------------------------------------------------------------
  275. #include <stdio.h>
  276. #include <nl_types.h>
  277.  
  278. #define SET 1
  279. #define MSG_HELLO 1
  280.  
  281. nl_catd catfd;
  282.  
  283. int main (int argc, char **argv) {
  284.         /* Open the message catalog. We use the basename of the program
  285.          * as the catalog name. Of course, several programs can also
  286.          * share a  common catalog.
  287.          */
  288.         catfd = catopen (basename (argv [0]), NL_CAT_LOCALE);
  289.         /* catgets returns message MSG_HELLO from set SET from the 
  290.          * message catalog catfd. If catfd does not refer to a message
  291.          * catalog, or the requested message cannot be found, the
  292.          * catalog, or the requested message cannot be found, the
  293.          * fourth argument is returned.
  294.          */
  295.         printf (catgets (catfd, SET, MSG_HELLO, "hello, world\n"));
  296.         catclose (catfd);
  297.         return 0;
  298. }
  299. -------------------------------------------------------------------------
  300.  
  301. For catopen, specify the constant NL_CAT_LOCALE to open the message
  302. catalog for the locale set for the LC_MESSAGES variable; using
  303. NL_CAT_LOCALE conforms to the XPG4 standard.  You can specify 0 (zero)
  304. for compatibility with XPG3; when oflag is set to zero, the locale set
  305. for the LANG variable determines the message catalog locale.
  306.  
  307. Several utilities exist for generating message catalogs and for
  308. upgrading programs which contain hard-wired strings:
  309. * gencat is used to generate message catalogs
  310. [All other programs are OS-specific:]
  311. * Ultrix and OSF support the extract program which will extract string
  312.   constants from the C source code, and has an option to replace these
  313.   strings with calls to catgets.
  314. * HP/UX has a similar utility called findmsg.
  315. * Under OSF, message catalogs may be listed with the dspcat utility.
  316. * HP/UX calls a similar utility dumpmsg.
  317.  
  318.  
  319. 5.2 Sun/Uniforum 
  320. Sun implements a different set of functions functions to support i18n
  321. of messages.  This mechanism is now also used by the GNU project to
  322. support localized error messages:
  323.  
  324. You can either use:
  325. -----------------------------------------------
  326.  
  327. main()
  328. {
  329.     // get the message catalog named "helloprogram" 
  330.     // for the hello world program
  331.     textdomain("helloprogram");    
  332.  
  333.     // get the translation for the "Hello, world\n" string
  334.     printf(gettext("Hello, world\n"));
  335. }
  336. -----------------------------------------------
  337.  
  338. or you can roll all in one and write
  339.  
  340. -----------------------------------------------
  341. main()
  342. {
  343.     // get the translation for the "Hello, world\n" string 
  344.     // from the message catalog "helloprogram"
  345.     printf(dgettext("helloprogram","Hello, world\n"));
  346. }
  347. -----------------------------------------------
  348.  
  349. The LC_MESSAGES locale category setting determines the locale of
  350. strings that gettext() returns.  The message catalogs are generated
  351. with either the installtxt or gencat commands.
  352.  
  353. No opening of files as in the old SYS V and X/Open routines, and no
  354. handling of message numbers that you must have in a database to
  355. administer.  However, this mechanism is only supported by Sun.  Sun
  356. tried to push it into COSE, but without success. 
  357.  
  358. This mechanism is available eithe with the Xview environment (the
  359. source is available with the XView code), or from the GNU project at
  360. ftp://prep.ai.mit.edu/pub/gnu/gettext-0.7.tar.gz. 
  361.  
  362.  
  363.  
  364. 5.3 POSIX language independent messages
  365. Neither of the previous two mechanisms is in the POSIX standard.
  366. There was much disagreement in the POSIX.1 committee about using the
  367. gettext routines vs. catgets (XPG).  In the end the committee couldn't
  368. agree on anything, so no messaging system was included as part of the
  369. standard. I believe the informative annex of the standard includes the
  370. XPG3 messaging interfaces, "...as an example of a messaging system
  371. that has been implemented..."
  372.  
  373. They were very careful not to say anywhere that you should use one set
  374. of interfaces over the other.
  375.  
  376.  
  377.  
  378. 6. Other localization aspects in ISO/ANSI C (and POSIX environments)
  379. For a more thorough discussion of localization and
  380. internationalization (aka. i18n), check your system vendors
  381. documentation, and the C library manual which comes with the FSF's
  382. glibc library (Chapter 19, 'Locales and Internationalization').
  383.  
  384.  
  385.  
  386. 7. Internationalization under X11
  387. While X11 is farther than most system software when it comes to
  388. internationalization, it still contains many bugs.  A number of bug
  389. fixes can be found at URL http://www.dtek.chalmers.se:80/~maf/i18n/.
  390.  
  391. 7.1 Output
  392. To output text encoded with ISO 8859-1 under X11, simply invoke the X
  393. display routines with 8 bit characters as you would use them with
  394. 7-bit ASCII.  You should however choose a font which contains bitmaps
  395. for these characters.  You can use the xfd utility to display a font
  396. to verify that it contains a full set of characters.
  397.  
  398.  
  399. 7.2 Input
  400. If you use a national keyboard (that is a keyboard, which has distinct
  401. keys for your countries special characters), inputting accents is
  402. straight forward and you'll get the corresponding characters by using
  403. the X11 input functions.
  404.  
  405. Sometimes it may be necessary to input characters for which there are
  406. no keys on your keyboard (e.g. if you want to enter the German '▀'
  407. from a French keyboard).  
  408.  
  409.  
  410. "X11R5 and X11R6 both have extensive support for i18n, but due to a
  411. variety of factors the R5 i18n was not well understood or widely
  412. used.  Many people resorted to a work-around and might have been
  413. disappointed when R6 did not include this feature.  It is important
  414. to recognize that the correct use of R5 and R6 i18n features will
  415. ensure maximum portability of your program." [X Consortium's view]
  416.  
  417. Unfortunately, not even the xterm terminal emulator supplied with the
  418. X11 distribution by the X Consortium supports this input method
  419. mechanism.  The lack of missing code samples (and support for this
  420. feature in some non-essential, but widely used X11 parts) may have
  421. contributed to this situation.
  422.  
  423.  
  424. Footnote: Amongst other reasons, the X Consortium decision not to add
  425. support for input methods to the Xaw Athena widget contributes to this
  426. situation.  Xaw is officially not supported by the X Consortium, and
  427. thus has only marginally been improved since X11R4.  However, many
  428. users (and much of the PD software) live in an Xaw-only world, so they
  429. will not be able to benefit from this i18n effort.
  430.  
  431. X11 R5 and R6 support input methods for entering non-ASCII, and
  432. displaying and configuring text, menus etc. for a wide variety of
  433. languages.  This input method has to be installed by the application
  434. by calls to the Xlib library (or an Xt toolkit call).
  435.  
  436. [Under X11R5, some X servers (notably the Xsun server) will let you
  437. enter ISO characters by supplying a built-in escape mechanism, if no
  438. keys for these characters are on your keyboard, and will pass along
  439. and display ISO 8859-1.  This hack obviated the need to install an
  440. input method, but was less flexible.]  
  441.  
  442.  
  443. If you are using a toolkit, it is quite simple to support localization
  444. of your X11 code: 
  445. If you're using a toolkit -- Xt and a widget set like Motif or R6 Xaw --
  446. you need only add a single line of code to your source. Before any other 
  447. calls to Xt, add a call to XtSetLanguageProc, e.g.:
  448.  
  449.     int main (int argc, char** argv)
  450.     {
  451.         ...
  452.         XtSetLanguageProc (NULL, NULL, NULL);
  453.         top = XtAppInitialize ( ... );
  454.         ...
  455.     }
  456.  
  457. The LANG and LC_xxx environment variables (see section 3) will then be
  458. used to determine the 'input method' for this X application.  This
  459. input method is responsible for managing COMPOSE character sequences
  460. or any other input mechanism for this particular implementation.  Also
  461. see section 9 of ftp://ftp.vlsivie.tuwien.ac.at/pub/8bit/FAQ-ISO-8859-1,
  462. the FAQ on ISO 8859-1 usage.
  463.  
  464.  
  465. 7.3 Toolkits, Widgets, and I18N
  466. The preferred way of inputing national characters when a national
  467. keyboard is not available is one/several input methods.  These input
  468. methods will then support various kinds of compose sequences to enter
  469. national characters.
  470.  
  471. The environment variables LANG and/or LC_xxx select the language for
  472. the Input Method (IM), but if several input methods exist, the
  473. environment variable XMODIFIERS can be used to select a specific input
  474. method.
  475.  
  476. Xlib, Xt and (partially) Xaw support IMs.  Thus, applications written
  477. with Xlib or Xt can support IMs (see section 7.2 on how to install
  478. input methods under Xt).
  479.  
  480. Motif 1.2  or greater automatically uses the R5/R6 input method APIs.
  481. Thus applications using Motif 1.2+ can be made to support IMs.
  482. Several Motif 1.[01] versions also had similar functionality added to
  483. them by the respective vendors, but these extensions are
  484. vendor-specific and not portable.
  485.  
  486. Xaw i18n is based upon X11R5 i18n, not on R6.  Thus, it supports R5
  487. input methods.  R6 added OUTPUT METHODS which are good for mainly
  488. R-to-L languages, and a few new INPUT METHODS (in-the-spot and I think
  489. one other) that Xaw might not support.  Xaw does support
  490. over-the-spot, off-the-spot, and root-window conversion.  To make this
  491. work, you might need to set "*international: True" in your resources.
  492.  
  493.  
  494. FOOTNOTE: If you can have comments/corrections for this section and on
  495.           OpenLook, please let me know.
  496.  
  497.  
  498. 7.4 I18N under X11R6, General Information
  499. Background information from the X11R6 announcement:
  500. Internationalization (also known as I18N, there being 18 letters between the
  501. i and n) of the X Window System, which was originally introduced in Release
  502. 5, has been significantly improved in R6.  The R6 I18N architecture follows
  503. that in R5, being based on the locale model used in ANSI C and POSIX, with
  504. most of the I18N capability provided by Xlib.  R5 introduced a fundamental
  505. framework for internationalized input and output.  It could enable basic
  506. localization for left-to-right, non-context sensitive, 8-bit or multi-byte
  507. codeset languages and cultural conventions.  However, it did not deal with
  508. all possible languages and cultural conventions.  R6 also does not cover all
  509. possible languages and cultural conventions, but R6 contains substantial new
  510. Xlib interfaces to support I18N enhancements, in order to enable additional
  511. language support and more practical localization.
  512.  
  513. The additional support is mainly in the area of text display.  In order to
  514. support multi-byte encodings, the concept of a FontSet was introduced in R5.
  515. In R6, Xlib enhances this concept to a more generalized notion of output
  516. methods and output contexts.  Just as input methods and input contexts sup-
  517. port complex text input, output methods and output contexts support complex
  518. and more intelligent text display, dealing not only with multiple fonts but
  519. also with context dependencies.  The result is a general framework to enable
  520. bi-directional text and context sensitive text display.
  521.  
  522. The description of the X11R6 internationalization framework is
  523. available via anonymous ftp from ftp.x.org in
  524. /pub/R6untarred/xc/doc/specs/i18n.
  525.  
  526.  
  527.  
  528. 8. Supporting I18N Network Protocols
  529. 8.1 MIME
  530. MIME is specified in RFC 1521 and RFC 1522 which are available from
  531. ftp.uu.net.  There is also a MIME FAQ which is available via anonymous
  532. ftp from ftp.ics.uci.edu in /mh/contrib/multimedia/mime-faq.txt.gz.
  533. (This file is in compressed format. You will need the GNU gunzip
  534. program to decompress this file.)
  535.  
  536. If you want to write applications which support the MIME protocol,
  537. there are several libraries/tools which can ease your task:
  538.  
  539.  
  540. 8.1.1 metamail
  541. Source for supporting MIME (the `metamail' package) in various mail
  542. readers is available via anonymous ftp from thumper.bellcore.com in
  543. /pub/nsb.  This distribution consists of several utilities, which can
  544. be called by MIME applications to handle MIME types.
  545.  
  546.  
  547. 8.1.2 MIMElt
  548. A "lightweight" MIME library available via anon ftp from
  549. oslonett.no:Software/MsDos/Comm/Offline/mimeltXX.zip 
  550.  
  551. It is source code (ANSI C) packaged as a library to facilitate
  552. construction of a limited MIME facility (limited == handling only
  553. character-set aspects of MIME, not the multimedia-aspects).  It
  554. includes hooks to recode character sets into whatever system you are
  555. running off (e.g.  if you read mail on a MsDos platform using CP-850,
  556. MIMElite may be set up so that QUOTED-PRINTABLE ISO Latin 1 is recoded
  557. into CP-850 for reading and saving to file).
  558.  
  559. It's main use is to provide programmers of so-called "off-line 
  560. readers" (used by users who access Internet mail through dial-up 
  561. service providers) with the tools needed to include proper support for 
  562. QUOTED-PRINTABLE encoding in their product.
  563.  
  564. The archive also contains a couple of sample applications that 
  565. demonstrates how the library may be used.  UNMIME is a stand-alone 
  566. utility to decode MIME-encoded messages (e.g. it works like UUDECODE
  567. for binary files with BASE64 encoding), SENDMIME is a simple utility
  568. to send MIME-encoded messages if your service provider doesn't have
  569. PINE or similar tools.
  570.  
  571. The current version (2.1) is limited to character set issues.  I am
  572. about to release version 2.2, which will support additional 
  573. Content-Types (e.g. "application/octet-stream").
  574.  
  575.  
  576.  
  577. 9. Programming in Prolog 
  578. Quintus Prolog and SICStus Prolog accepts ISO characters as part of
  579. atoms, so you can even define goal names containing accented
  580. characters.  I/O of 8 bit characters is (obviously) also supported.
  581.  
  582. Quintus Prolog also can handle Kanji.
  583.  
  584.  
  585. 10. Unicode
  586.  
  587. Support for wide characters has been incorporated in a number of new
  588. operating system offerings, including SVR4 compliat systems (e.g.,
  589. Solaris 2.x, Unixware, IRIX5/6, Sony NEWSOS 6.x).  Other systems which
  590. support wide characters are Digital Unix (nee OSF/1), DEC Ultrix
  591. (version 4.x), SunOS (as of version 4.1.x), HPUX 9 and 10, AIX 3 and
  592. 4, several public BSD versions (FreeBSD, NetBSD, BSD/OS) as well as
  593. Linux, although the Linux locale support is weak.
  594.  
  595. Note that 'support for Unicode' means different things to different
  596. people.  Thus, Unix vendors claim Unicode support if they fulfill the
  597. following:
  598. * They define wchar_t in stddef.h. 
  599. * They have ANSI functions mblen, mbstowcs, wctomb, mbtowc, and wcstombs. 
  600. * The remaining infrastructure (file names, program names, shells,
  601.   systems programs, etc.) is still at 8 bit characters.
  602.  
  603. Note that support for wchar_t and the mentioned ANSI functions is
  604. enopugh to write Unicode programs.  You can even use Unicode
  605. characters in falinames, if you use an 8 bit file-system safe
  606. transformation for Unicode.
  607.  
  608. Footnote: Transformations are Unicode magic: in order to comply with
  609.           exisitng infrastructure, Unicode can be 'transformed' into a
  610.           variety of encodings: 8 bit, 16 bit, file system safe, etc.etc. 
  611.           When needed, these transformations are then transformed back
  612.           into a canonical Unicode form.
  613.  
  614. However, you may not be able to process these filenames properly from
  615. within your other favorite programs, and they might not even display
  616. correctly, depending on you output devices.  Thus, even simple
  617. operations such as 'mv', 'cp' or file redirection may be problematic!
  618.  
  619. Wide character strings have no locale info associated with them so would 
  620. be meaningless in the wrong locale. You never write files of wchar_t, you 
  621. always convert the data to multi-byte format. The same rationale would 
  622. apply to filenames in the file system, exec parameters, shells, etc. 
  623. Since the API for doing these thing all use char or char* it would be
  624. very difficult to get wchar_t data to be used. 
  625.  
  626. The only OS I know of that uses Unicode is MS WindowsNT and this is one 
  627. of the difficulties in exporting NTFS file systems to Unix. The APIs for
  628. things like (f)open, etc., are all ANSI, so the library or the kernel
  629. must convert the ASCII string into a Unicode wchar_t string. (NT doesn't
  630. have the exec* family of functions, it uses spawn*, which all take
  631. char or char* arguments.)  All system calls under NT have ASCII and
  632. Unicode variations.  Internally, the ASCII versions seem to translate
  633. to Unicode, but this is just a guess.
  634.  
  635. I'm not aware of any Unix that has support for ISO-10646 (or Unicode) yet.
  636. X has preliminary support for it in R6, but it only supports CJK and
  637. ASCII at this point in time and it would be difficult, if not impossible
  638. to use given that there is no underlying OS support for it.
  639.  
  640. ACK: Thanks to Kaleb Keithley who explained these concepts to me. 
  641.      All errors are mine.
  642.  
  643.  
  644. 11. ISO 8859-1 on non-UNIX systems
  645. 11.1 MS-DOS
  646. MS-DOS generally uses its own characters set. There are several code
  647. pages (one with the same symbols as ISO 8859-1, albeit at different
  648. character code positions, which can lead to problems with the transfer
  649. of data).
  650.  
  651. If interoperability without data conversion is your goal, you can
  652. reconfigure your MS-DOS PC to use an ISO-8859-1 code page. Check out
  653. the anonymous ftp archive ftp.uni-erlangen.de, which contains data on
  654. how to do this (and other ISO-related stuff) in /pub/doc/ISO/charsets.
  655. The README file contains an index of the files you need.
  656.  
  657. Most (all?) C compilers/libraries for MS-DOS have only minimal support
  658. for the ANSI/POSIX locale mechanism.  The setlocale() and localeconv()
  659. calls (and stuff like strxfrm()) are generally hardwired.
  660.  
  661.  
  662. 11.2 MS Windows
  663. MS-Windows (using code page 1252) normally uses the first 256
  664. characters of Unicode, which is (for all practical purposes)
  665. equivalent to ISO 8859-1.  Thus, data representation and conversion
  666. for interoperability with other ISO 8859-1 compliant systems is not an
  667. issue.  
  668.  
  669. It seems that C libraries for MS Windows do not support the ANSI/POSIX
  670. locale mechanism. (If you have any experiences with that, please let
  671. me know.)  There is a POSIX-like mechanism in some Microsoft platform
  672. services, but none in the compilers from any vendor.
  673.  
  674. Windows NT supports Unicode, which is a super-set of ISO 8859-1.
  675. There does not seem to be support for the locale mechanism under
  676. Windows NT.
  677.  
  678.  
  679. 11.3 OS/2
  680. Text mode OS/2 programs generally suffer the same limitations as do
  681. MS-DOS programs, because the display hardware is the same.
  682.  
  683. Presentation Manager OS/2 programs using code page 1004 will order
  684. the font glyphs in the same sequence as ISO 8859-1 (although of
  685. course whether the glyphs will actually look anything like those
  686. from ISO 8859-1 depends entirely from the font).
  687.  
  688. The IBM CSet++ compiler supports full internationalization, with
  689. several predefined locales.
  690.  
  691. The Borland C++ compiler supports only the "C" locale.
  692.  
  693. The Watcom C++ compiler supports only the "C" locale.
  694.  
  695. The Metaware High C++ compiler supports only the "C" locale.  It
  696. does, however, also support UNICODE, providing UNICODE character
  697. types and UNICODE versions of the appropriate parts of the standard
  698. library (including I/O).
  699.  
  700.  
  701.  
  702. 11.4 Apple Macintosh
  703. MacIntoshes have their own non-standard character encodings; the first
  704. 128 characters are US-ASCII but the remaining characters are
  705. non-standard.  If you connect to the rest of the world, NCSA telnet
  706. does support ISO 8859-1.
  707.  
  708. Symantec's THINK C provides setlocale() is provided for ANSI C
  709. compatibility only.  Only the minimal "C" locale is implemented.
  710. It doesn't change your program's locale.
  711.  
  712. I do not know whether C libraries (for which compilers?) for the
  713. MacIntosh support the ANSI/POSIX locale mechanism. If you have any
  714. experiences with that, please let me know.
  715.  
  716. In fact the Macintosh has very good i18n facilities, but they are
  717. accessed through non-ANSI-standard things like the Script Manager, so
  718. they are useless for people who want to write portable programs.
  719.  
  720.  
  721. 11.5 DEC OpenVMS (Alpha and Vax systems)
  722. DEC recently implemented support for the XPG4 world-wide portability
  723. interfaces as well as XPG4 message catalogs. You need DEC C V5.0 and
  724. OpenVMS V6.2 (for either Alpha or VAX systems)
  725.  
  726.  
  727. 11.6 Amiga
  728. The AmigaOS uses ISO-8859-1. As of OS version 2.1, Amiga-specific
  729. means of localization are available.
  730.  
  731.  
  732.  
  733. 12. Home location of this document
  734. 12.1 www
  735. You can find this and other i18n documents under URL
  736. http://www.vlsivie.tuwien.ac.at/mike/i18n.html.
  737.  
  738. 12.2 ftp
  739. The most recent version of this document is available via anonymous
  740. ftp from ftp.vlsivie.tuwien.ac.at under the file name
  741. /pub/8bit/i18n-programming.  
  742.  
  743.  
  744. -----------------
  745.  
  746. Copyright ⌐ 1994,1995 Michael Gschwind (mike@vlsivie.tuwien.ac.at)
  747.  
  748. This document may be copied for non-commercial purposes, provided this
  749. copyright notice appears.  Publication in any other form requires the
  750. author's consent. (Distribution or publication with a product requires
  751. the author's consent, as does publication in any book, journal or
  752. other work.)
  753.  
  754. Dieses Dokument darf unter Angabe dieser urheberrechtlichen
  755. Bestimmungen zum Zwecke der nicht-kommerziellen Nutzung beliebig
  756. vervielfΣltigt werden.  Die Publikation in jeglicher anderer Form
  757. erfordert die Zustimmung des Autors.  (Verteilung oder Publikation mit
  758. einem Produkt erfordert die Zustimmung des Autors, wie auch die
  759. Ver÷ffentlichung in Bⁿchern, Zeitschriften, oder anderen Werken.)
  760.  
  761.  
  762. Michael Gschwind, Institut f. Technische Informatik, TU Wien
  763. snail: Treitlstrasse 3-182-2 || A-1040 Wien || Austria
  764. email: mike@vlsivie.tuwien.ac.at   PGP key available via www (or email)
  765. www  : URL:http://www.vlsivie.tuwien.ac.at/mike/mike.html
  766. phone: +(43)(1)58801 8156       fax: +(43)(1)586 9697
  767. Multiculturalism is the concept that European cultures should be
  768. flexible enough to accommodate the inflexibility of all others.
  769.